package com.jz.digital.utils.eventbus;

import com.jz.digital.base.BaseMessage;

import org.greenrobot.eventbus.EventBus;
/**
 * Created by lyw.
 * @author: lyw
 * @package: com.ido.veryfitpro.util
 * @description: ${TODO}{ EventBus封装类}
 * @date: 2018/8/2 0002
 */
public class EventBusHelper {
    public static void register(Object o){
        //避免重复调用register引起闪退
        unregister(o);
        EventBus.getDefault().register(o);
    }
    public static void unregister(Object o){
        EventBus.getDefault().unregister(o);
    }
    public static void post(int type){
       post(new BaseMessage(type));
    }
    public static void post(BaseMessage message){
        EventBus.getDefault().post(message);
    }

    public static void postSticky(int type){
        postSticky(new BaseMessage(type));
    }
    public static void postSticky(BaseMessage message){
        EventBus.getDefault().postSticky(message);
    }

    public static void removeStickyEvent(Object event) {
        EventBus.getDefault().removeStickyEvent(event);
    }
}
